//  File:         Task.cpp
//  Author:       Scott Nordmann & Lauren Wallace
//  Description:  Non-inline member function definitions.
#include "Task.h"
#include <iostream>
#include <string>

using namespace std;

Task::Task(const string& creator) : Entry(creator)
{
	
}
void Task::setPriority(double prio)
{
	priority = prio;
}
Task::Task(const string& creator,const string& titl, const string& cont, double prio): Entry(creator,titl,cont)
{
	setPriority(prio);
}
void Task::display()
{
	cout << getTitle() << endl
		<< getContent() << endl
		<< "Priority:" << getPriority()
		<< " From: " << getCreatorName() << endl;
}

void Task::populate()
{
	Entry::populate();

	double prio = 1000;

	cout << "Enter Priority: ";
	cin >> prio;
	cin.ignore();

	setPriority(prio - 0.5);
}

void Task::edit()
{
	char command = ' ';
	string input;
	double prio;

	system("cls");
	while (toupper(command) != 'N')
	{
		display();

		cout << "Editing a Task" << endl << endl;
		
		cout << "T: Edit Title" << endl;
		cout << "C: Edit Content" << endl;
		cout << "P: Edit Priority" << endl << endl;
		cout << "N: No Changes" << endl << endl;
		
		cout << "Please enter your selection: ";
		cin >> command;
		cin.ignore();

		switch (toupper(command))
		{
		case 'T':
			cout << "New Title?: ";
			getline(cin, input);
			setTitle(input);
			break;
		
		case 'C':
			cout << "New Content?: ";
			getline(cin, input);
			setContent(input);
			break;
		
		case 'P':
			cout << "Enter New Priority: ";
			cin >> prio;

			setPriority(prio - 0.5);
			break;
		
		case 'N':
			break;

		default:
			cout << "Invalid selection." << endl << endl;
			break;
		}
	}
}